<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 14, 2009 at 3:35:17 pm</time-stamp>


<class>
<name>CheapestItemFirstPolicyTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>i1 i2 i3 i4 retailer </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id>
<body>A test case for the CheapestItemFirstPolicy

Instance Variables:
	i1	&lt;Item&gt;	The cheapest item
	i2	&lt;Item&gt;	The most expensive item
	i3	&lt;Item&gt;	The earliest-arrived item
	i4	&lt;Item&gt;	The last-arrived item
	retailer	&lt;Retailer&gt;	The retailer we're trying to sell with

</body>
</comment>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	| inventory |
	inventory := Inventory new.
	i1 := Item named: 'Taco' sku: '123456'.
	i1 quantity: 10.
	i1 buyPrice: 8.
	i1 dateRecieved: (Date newDay: 4 monthNumber: 6 year: 2008).
	inventory addItem: i1.
	i2 := Item named: 'Taco' sku: '123456'.
	i2 quantity: 10.
	i2 buyPrice: 20.
	i2 dateRecieved: (Date newDay: 5 monthNumber: 7 year: 2008).
	inventory addItem: i2.
	i3 := Item named: 'Taco' sku: '123456'.
	i3 quantity: 10.
	i3 buyPrice: 10.
	i3 dateRecieved: (Date newDay: 10 monthNumber: 2 year: 2008).
	inventory addItem: i3.
	i4 := Item named: 'Taco' sku: '123456'.
	i4 quantity: 10.
	i4 buyPrice: 11.
	i4 dateRecieved: (Date newDay: 1 monthNumber: 10 year: 2008).
	inventory addItem: i4.
	
	retailer := Retailer new.
	retailer inventory: inventory.
	retailer sellPolicy: CheapestItemFirstPolicy new.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.CheapestItemFirstPolicyTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="testCheapestItem">testCheapestItem
	"Tests that the cheapest item (i1) is selected to sell"

	| soldItem |
	soldItem := retailer sellItem: i1.
	self assert: (soldItem == i1).</body>
</methods>

</st-source>
